#include "mainwidget.h"
#include <QtGui>
#include "lightplot2d.h"

MainWidget::MainWidget(QWidget *parent)
    : QWidget(parent)
{
    lightPlot2D = new LightPlot2D;
    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addWidget(lightPlot2D);
    setLayout(mainLayout);

    QVector<QPointF> v1;
    QVector<QPointF> v2;
    QVector<QPointF> v3;
    for (int i = 0; i < 100; ++i) {
        double x = i * 0.01;
        double y = sin(10.0 * x);
        y *= y;
        v1.append(QPointF(x, y));
        v2.append(QPointF(x, y*x));
        v3.append(QPointF(x, x*x*y*y));
    }

    CurveData cd1;
    cd1.setData(v1);
    cd1.setColor(Qt::red);
    cd1.setSymbol(Rhombus);
    cd1.setSymbolSize(5);
    cd1.setPenStyle(Qt::NoPen);
    cd1.setLegend("<i>Curve 1</i>");

    CurveData cd2;
    cd2.setData(v2);
    cd2.setColor(Qt::blue);
    cd2.setSymbolSize(5);
    cd2.setSymbol(TriangleUp);
    cd2.setPenStyle(Qt::DashDotLine);
    cd2.setLegend("<i>Curve 2</i>");

    CurveData cd3;
    cd3.setData(v3);
    cd3.setColor(Qt::darkGreen);
    cd3.setSymbolSize(5);
    //cd3.setSymbol(TriangleUp);
    cd3.setPenStyle(Qt::DashLine);
    cd3.setLegend("<i>Curve 3</i>");

    lightPlot2D->plotter()->setCurveData(cd1);
    lightPlot2D->plotter()->setCurveData(cd2);
    lightPlot2D->plotter()->setCurveData(cd3);
    lightPlot2D->plotter()->setNameYAxis("<i>Axis</i> X");
    lightPlot2D->plotter()->setNameXAxis("<i>Axis</i> Y");
}

MainWidget::~MainWidget()
{
}
